package cn.gtlc;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * TODO
 *
 * @author Jowin
 * @date 2021/8/5
 */
public class DevClass {
    private Integer id;
    private String name;

    public DevClass() {
    }

    public DevClass(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    /**
     * 获取
     *
     * @return id
     */
    public Integer getId() {
        return id;
    }

    /**
     * 设置
     *
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    public String toString() {
        return "DevClass{id = " + id + ", name = " + name + "}";
    }

    public static void main(String[] args) throws IOException {
        BASE64Encoder encoder = new BASE64Encoder();
        String str = "{\"user\":\"周jowin\",\"pwd\":\"123\"}";
        String encode = encoder.encode(str.getBytes(StandardCharsets.UTF_8));
        System.out.println("encode==>" + encode);

        BASE64Decoder decoder = new BASE64Decoder();
        byte[] bytes = decoder.decodeBuffer(encode);
        System.out.println(new String(bytes));

        System.out.println("================================");

        /*String encode1 = Base64Encoder.encode(str);
        System.out.println("encode1:" + encode1);
        byte[] decode = Base64Decoder.decode(encode1.getBytes(StandardCharsets.UTF_8));*/

        //System.out.println(new String(decode));
        //
    }
}
